<?php
$paging = new paging();
$mod = $_GET['mod'];
$curpg = $_GET['curpg'];
$curpg = (isset($curpg)) ? $curpg : 1;
$gotopage = '?mod=' . $mod . "&act=list";

$table = "media_item";
$totalrows = find("select * from $table",'count');

$query = "select * from $table order by orderId, id asc limit " . (($curpg - 1) * $perpage) . ", " . $perpage;
$items = find($query);

require_once 'include/js_for_list.php';
?>

<div class="page-header">
    <div class="pull-left">Media list</div>
    <div class="pull-right"></div>
    <div class="clear"></div>
</div>

<form name="frmlist" method="post" action="">
    <div class="pull-left">
        <a href="javascript:docheckallnew(false, document.frmlist.chkid)" >Deselect All</a> |
        <a href="javascript:docheckallnew(true, document.frmlist.chkid)" >Select All</a>
    </div>
    <div class="pull-right">
        <img src="images/icons/add.png" onclick="add();" class="pointer"/> 
        <img src="images/icons/delete.png" onclick="delall();" class="pointer"/> 
    </div>
    <div class="clear"/>

    <table width="100%" border="0" cellpadding="0" cellspacing="1" class="gridtitle">
        <tr>
            <td  class="gridtitletitle">
                <div class="divcheck">&nbsp;</div>
                <div class="divtitle">Title</div>
                <div class="divaction">Action</div>											</td>
        </tr>

        <tr >
            <td >
                <div id="changeNotificationNo"> </div>  
                <div id="sortlist">  												
                    <?php
                    foreach ($items as $key => $row) {

                        if ($key + 1 % 2 == 1)
                            $listitem = "griditem1";
                        else
                            $listitem = "griditem2";
                        ?>
                        <li class="<?= $listitem ?>" onMouseOver="mOvr(this, 'bgover')" onMouseOut="mOut(this, '<?= $listitem ?>')" id="pictureId_<?= $row['id'] ?>">
                            <div class="divcheck"><input type="checkbox" name="chkid" value="<?= $row["id"] ?>" /></div>
                            <div class="divtitle"><?= $row['title'] ?></div>
                            <div class="divaction"> <img src="images/icons/edit.png" onclick="edit('<?= $row["id"] ?>')" class="pointer"/>&nbsp;&nbsp;&nbsp;<img src="images/icons/del.png" onclick="del('<?= $row["id"] ?>')" class="pointer" /></div>
                            <div class="clr"></div>
                        </li>

                    <?php
                    }
                    ?>   
                </div>	</td>	
        </tr>
    </table>
    <table width="100%" border="0" cellspacing="0">

        <tr>
            <td colspan="2" align="left" valign="middle" class="titlepage"><?= $lb_tottalrow ?>  <span class="numpage"><?= $totalrows ?></span> </td>
            <td colspan="3" align="right" valign="top" class="numpage"><?php echo $paging->pagenew($totalrows, $perpage, $pagecount, $curpg, $gotopage, "","titlepage");?></td>
        </tr>

    </table>

    <input type="hidden" name="form_" value="delete" />		
    <input type="hidden" name="listid" value="" />
    <input type="hidden" name="curpg" value="<?= $curpg ?>" />
</form>	